#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int f(int n)
{
	if (n<=4) return n;
	return f(n - 1) + f(n - 3);
}
int main()
{
	int n;
	while (cin >> n && n)
	{
		cout << f(n) << endl;
	}
	return 0;
}